package main

import "fmt"

//#link:  https://leetcode-cn.com/problems/n-th-tribonacci-number/
func main() {
	n := 4
	fmt.Println(tribonacci(n))
}

func tribonacci(n int) int {
	switch n {
	case 0:
		return a
	case 1, 2:
		return b
	}
	//sum:=[]int{0,1,1}
	a, b, c := 0, 1, 1
	result := 0
	for i := 3; i <= n; i++ {
		result = a + b + c
		a, b, c = b, c, result
	}

	return result
}
